//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    public class ValueAxis : Axis
    {
        private const string name = "valAx";
        private CrossBetween? _crossBetween;

        private DisplayUnits _dispUnits;
        private double? _majorUnit;
        private double? _minorUnit;
        //internal IChartWithDisplayInformation Owner;

        public DisplayUnits DisplayUnits
        {
            get { return _dispUnits; }
            set { _dispUnits = value;notifyPropertyChanged("DisplayUnits"); }
        }

        public CrossBetween? CrossBetween
        {
            get { return _crossBetween; }
            set { _crossBetween = value; notifyPropertyChanged("CrossBetween"); }
        }

        public double? MajorUnit
        {
            get { return _majorUnit; }
            set
            {
                _majorUnit = value;
                notifyPropertyChanged("MajorUnit");
            }
        }

        public double? MinorUnit
        {
            get { return _minorUnit; }
            set
            {
                _minorUnit = value;
                notifyPropertyChanged("MinorUnit");
            }
        }

       

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read(name))
            {
                ReadXmlBase(c);
                CrossBetween = c.ReadOptionalElementEnumAttribute<CrossBetween>("crossBetween", "val"); //\\defaults
                MajorUnit = c.ReadOptionalElementDoubleAttribute("majorUnit", "val");
                MinorUnit = c.ReadOptionalElementDoubleAttribute("minorUnit", "val");
                DisplayUnits = c.ReadOptionalElement<DisplayUnits>("dispUnits");
                c.WarnIf("crtExt");
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                WriteXmlBase(c);

                /*e.WriteOptionalInteger("crossAx", crossAx);
                e.WriteOptionalEnum<Crosses>("crosses", Crosses);
                e.WriteOptionalDouble("crossesAt", CrossesAt);*/
                c.WriteOptionalElementEnumAttribute("crossBetween", CrossBetween);
                c.WriteOptionalElementDoubleAttribute("majorUnit", MajorUnit);
                c.WriteOptionalElementDoubleAttribute("minorUnit", MinorUnit);
                c.WriteOptionalElement(DisplayUnits);
                c.WarnIf("extstuff");
                //\\
            }
        }
    }
}